//
//  DEWMyRingViewController.m
//  OtherDemo
//
//  Created by kangbinbin on 2018/7/29.
//  Copyright © 2018年 lianjie. All rights reserved.
//

#import "DEWMyRingViewController.h"
#import "UIBarButtonItem+MainBar.h"
#import "DEWMyRingCell.h"
#import "DEWRingPeopleViewController.h"
static NSString *const cellID = @"myring";
@interface DEWMyRingViewController ()<UITableViewDelegate,UITableViewDataSource>
/** <#type#> */
@property (strong, nonatomic) UITableView  *tableView;

@end

@implementation DEWMyRingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    
    [self createView];
    
}

#pragma mark ----RequestData
-(void)loadData
{
    
    
}

#pragma mark ----initView
-(void)createView
{
    self.navigationItem.title = @"我的圈子";
    
    UIBarButtonItem *rightItem = [UIBarButtonItem itemWithTarget:self action:@selector(rightBarButtonItemClick) image:nil highImage:nil andTitle:@"创建圈子"];
    
    self.navigationItem.rightBarButtonItem = rightItem;
    
    [self creatTab];
    
}
#pragma mark - 创建圈子按钮点击事件
-(void)rightBarButtonItemClick{
    
}

-(void)creatTab{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , DEWScreenHeight - NAVH) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    if (@available(iOS 11.0, *)){
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.tableView.estimatedRowHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
    }
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([DEWMyRingCell class]) bundle:nil] forCellReuseIdentifier:cellID];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }else{
        return 10;
    }
    
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DEWMyRingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 80;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *HeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , 40)];
    HeaderView.backgroundColor = UIColorFromRGB(0xF2F2F2);
    
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(10, 10, DEWScreenWidth - 20, 20);
    NSArray *arr =@[@"我创建的圈子",@"我加入的圈子"];
    label.text = arr[section];
    label.textColor = Color_99;
    label.font = [UIFont systemFontOfSize:12];
    [HeaderView addSubview:label];
    
    return HeaderView;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    DEWRingPeopleViewController *people = [[DEWRingPeopleViewController alloc]init];
    [self.navigationController pushViewController:people animated:YES];
}

@end
